#include <EIKENV.H>
#include <EIKAPPUI.H>
#include <aknutils.h>
#include <eikapp.h>
#include "SplashScreen.h"
 
_LIT(KtxMySplashImage, "\\resource\\apps\\CDTSplash.mbm" );
 
CSplashScreen::~CSplashScreen()
{
	delete iBgPic;
}   
 
CSplashScreen* CSplashScreen::NewL(void)
    {
    CSplashScreen* self = new(ELeave)CSplashScreen();
    CleanupStack::PushL(self);
    
    self->ConstructL();
    
    CleanupStack::Pop(self);
    return self;
    }
 
void CSplashScreen::ConstructL(void)
    {
    CreateWindowL();
	SetRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect());
 
	TFindFile AppFile(CCoeEnv::Static()->FsSession());
 
	if(KErrNone == AppFile.FindByDir(KtxMySplashImage, KNullDesC))
	{			
		iBgPic = new (ELeave) CFbsBitmap();
		User::LeaveIfError(iBgPic->Load(AppFile.File(),0));	
	}
 
	ActivateL();
	DrawNow();
}
 
void CSplashScreen::Draw(const TRect& /*aRect*/) const
{
	CWindowGc& gc = SystemGc();
 
  	gc.SetBrushColor(KRgbWhite);
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.Clear(Rect());
 
    if(iBgPic)
	{
		if(iBgPic->Handle())
		{
			gc.DrawBitmap(Rect(),iBgPic);
		}	
	}
}
